#input thread_id,and view its posts

import wsgiref.handlers

from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from BeautifulSoup import BeautifulSoup

from xmw import tianya

from xmw import error
import os
import urllib2, urllib
import uuid
from xmw.db import ds
from google.appengine.ext import webapp
import __main__
from appengine_utilities import sessions
import logging
import xmw
import datetime

class MainPage(xmw.RequestHandler):

    def get(self):
        self.sess = sessions.Session()
        self.cookie_sess = sessions.Session(writer="cookie")          
        session_user =None
        if self.sess.has_key("user"):
            session_user=self.sess["user"]
        else:
            login_action=ds.Login_Action()
            self.sess['login_action']   =login_action
            login_action.action ="/my_ximenwai"
            login_action.params="s"
            login_action.created=datetime.datetime.now()
            login_action.put()
            template_values ={"session_user":session_user}
            self.render_template(template_values, "../html/login.html")
            return
        
        logging.log( logging.INFO, "session_user :%s"%str(session_user))
        template_values ={"session_user":session_user}
        self.render_template(template_values, "../html/my_ximenwai.html")
        return

def main():
    application = webapp.WSGIApplication(
                                       [('/my_ximenwai', MainPage)],
                                       debug=True)
    wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
  main()
